package cn.highedu.spring.bean17;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class MyConfigurationCustomizer implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory)
            throws BeansException {
        // 通过beanFactory可以获取bean的定义信息，进而可以修改bean的定义信息
        // 这里将transferService的scope修改为prototype
        BeanDefinition beanDefinition = configurableListableBeanFactory.getBeanDefinition("transferService");
        beanDefinition.setScope("prototype");
    }
}
